import request from '@/hooks/request'

const Api = {
  filmOrderList: '/film/order/filmOrderList', // 订单列表
  orderIntercept: '/film/order/orderIntercept', // 尝试拦截
  filmOrderListAdmin: 'film/order/filmOrderListAdmin', // 订单列表 - 管理员专用
  orderRefund: '/film/order/orderRefund', // 订单列表 - 订单退款
  orderSettle: '/film/order/orderSettle',
  orderDetail: '/film/order/getFilmOrder', //订单详情
  orderDetailAdmin: '/film/order/orderDetailAdmin', //订单详情 - 管理员专用
  filmOrderExcelOut: '/film/order/filmOrderExcelOut', //订单导出
  ownOutTicketCount: '/film/orderFlow/ownOutTicketCount', //用于获取电影订单的出票数量
  OwnOutTicketList: '/film/orderFlow/orderFlowList', //获取当前的订单列表自行出票
  cancelOrder: '/film/orderFlow/closeOpenOrder', //取消放单
  submitFilmOrder: '/film/orderFlow/submitTicket', //提交电影订单
  submitPayOrder: '/film/orderFlow/automaticSubmitOrder', //提交支付订单
}
// 导出一个函数，用于获取电影订单的出票数量
export const filmOrderOwnOutTicketCount = () => {
  return request({
    method: 'post',
    url: Api.ownOutTicketCount,
  })
}

export const submitFilmOrderByOwn = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.submitFilmOrder,
    data: parameter,
  })
}

export const submitFilmPayOrder = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.submitPayOrder,
    data: parameter,
  })
}

export const cancelFilmOrder = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.cancelOrder,
    data: parameter,
  })
}

// 导出一个函数，用于获取电影订单的列表
export const getOwnOutTicketList = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.OwnOutTicketList,
    data: parameter,
  })
}
export const filmOrderExcelOut = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.filmOrderExcelOut,
    data: parameter,
    responseType: 'blob',
  })
}

export const filmOrderList = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.filmOrderList,
    data: parameter,
  })
}

export const orderIntercept = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('id', parameter.id)
  return request({
    method: 'post',
    url: Api.orderIntercept,
    data: formData,
  })
}

export const filmOrderListV2 = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.filmOrderListAdmin,
    data: parameter,
  })
}

export const orderRefund = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.orderRefund,
    data: parameter,
  })
}

export const orderSettle = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('orderId', parameter.orderId)
  return request({
    method: 'post',
    url: Api.orderSettle,
    data: formData,
  })
}
export const getOrderDetail = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('id', parameter.id)
  return request({
    method: 'post',
    url: Api.orderDetail,
    data: formData,
  })
}

export const orderDetailAdmin = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('id', parameter.id)
  return request({
    method: 'post',
    url: Api.orderDetailAdmin,
    data: formData,
  })
}
